<template>
    <div id="app">
      <el-form :model="clazz" label-width="100px">

        <el-form-item label="班级名" prop="name">
          <el-input v-model="clazz.name"></el-input>
        </el-form-item>

        <el-form-item label="辅导员">
          <el-select v-model="clazz.headTeacher">
            <el-option v-for="(item,index) in teacherList" :key="index" :label="item.name" :value="item.id"></el-option>
          </el-select>
        </el-form-item>

        <el-form-item label="专业">
          <el-input v-model="clazz.major"></el-input>
        </el-form-item>

        <el-form-item label="描述">
          <el-input v-model="clazz.description"  type="textarea" rows="5"></el-input>
        </el-form-item>


        <el-form-item>
          <el-button type="primary" @click.prevent="test">保存</el-button>
        </el-form-item>
      </el-form>
    </div>
</template>

<script>
    export default {
      data(){
        return {
          clazz:{},
          teacherList:[]
        }
      },
      created(){
        this.axios.get("/teacher/selectAll").then(resp=>{
          this.teacherList=resp.data;
        })
      },
      methods:{
        test(){
            this.$confirm("是否确认提交","保存提示").then(()=>{
              this.axios.post("/class/add",this.clazz).then((resp)=>{
                  this.$message.success("保存成功！");
                  this.$router.push("/student/ClassList")
                });
            });
        }
      }
    }
</script>


<style scoped>

</style>
